<template>
  <drawer-edit-layout ref="layout" :title="params.title" :show="params.show" :disable="params.disable" :loading="page.process.form" @invoke="invoke">
    <el-form v-if="!page.process.form" ref="form" :model="form" size="default" label-width="80px">
      <el-form-item label="货品分类" prop="name" :rules="page.rules.def">
        <form-remote-select
          v-model="form.categoryId"
          placeholder="货品分类"
          :url="service.conf.api.get('wms').url+'/api/gds/category-info/map'"
        />
      </el-form-item>
      <el-form-item
        label="编码"
        prop="no"
        :rules="{
          validator:page.rules.remote,
          url:page.router.remoteUrl+'/existNo/',
          params:{no:form.no,id:form.id
          }, trigger: 'blur'}"
      >
        <el-input
          v-model="form.no"
          :disabled="form.id!=null"
          class="col"
          placeholder="请输入编码"
        />
      </el-form-item>
      <el-form-item label="名称" prop="name" :rules="page.rules.def">
        <el-input v-model="form.name" class="col" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="名称" prop="picture" :rules="page.rules.def">
        <form-upload-image v-model="form.picture" size="mini" :remote="upload.img" />
      </el-form-item>

      <el-form-item label="优先级" prop="priority" :rules="page.rules.number">
        <el-slider
          v-model="form.priority"
          :step="1"
          :max="10"
          :min="0"
          show-stops
        />
      </el-form-item>
    </el-form>
  </drawer-edit-layout>
</template>
<script>
import adminSupport from 'lola-admin-support-el'

export default {
  name: 'ProductManageEdit',
  mixins: [adminSupport.mixins.drawerEdit],
  props: {
  },
  data() {
    return {
      name: 'ProductManage',
      form: {},
      params: {
        id: 0,
        title: '',
        show: false,
        disable: false
      }
    }
  },
  watch: {
    'params.id': function(n, o) {
      // this.loadData()
    }
  },
  created() {
    // this.init()// 初始化
  },
  methods: {
    init(params) {
      this.params = params
      this.loadData()
    },
    appendForm() {
      if (this.form.parent == null) {
        this.form.parent = { id: null, name: null }
      }
      let powerIds = []
      if (!String.isNullOrEmpty(this.form.powerIds)) {
        powerIds = this.form.powerIds.split(',')
      }
      this.form.powerIds = powerIds
    }, buildForm() {
      this.form.powerIds = this.form.powerIds.join(',')
      return true
    }
  }
}
</script>
